﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Linq.Dynamic;

using TempEmployees.DAL;
using TempEmployees.BLL.Database;

namespace TempEmployees.BLL.EntitiesExtensions
{
    public static class EBaseSalary 
    {
        public static List<BaseSalary> GetOrderedBaseSalaries()
        {
            return DbQuery.Database.BaseSalaries.OrderBy("ValidFromDate DESC").ToList();
        }

        public static BaseSalary CurrentBaseSalary
        {
            get { return GetOrderedBaseSalaries().First(); }
        }

        public static bool Update(BaseSalary baseSalary)
        {
            try
            {
                DbQuery.Insert<BaseSalary>(baseSalary);
                return true;
            }
            catch
            {
                return false;
            }
        }
    }
}
